<?php
##############################################
#
#   商铺
# @ Time : 2017-1-8 - 下午9:20:27
# @ Author : JiangYongWei <1085562810@qq.com>
# @ Encoding : UTF-8 language : PHP
#
##############################################


namespace Admin\Model;
use Admin\Model\AdminBaseModel;

class PartUserModel extends AdminBaseModel{
	/*参与抽奖用户表 */
	//protected $tableName = 'part_user';
    /**
     * 获取所有抽奖用户
     */
    public function getUser($where){
        if($where)
        {
            $map['activity_name'] = array('like','%'.$where['activity_name'].'%');
            $map['user_name'] = array('like','%'.$where['user_name'].'%');
        }

        $starttime = strtotime($where['starttime']);
        $endtime = strtotime($where['endtime']);
        if ($starttime && $endtime)
            $map['time'] = array('between',array($starttime,$endtime));
        elseif ($starttime)
            $map['time'] = array('egt',$starttime);
        elseif ($endtime)
            $map['time'] = array('elt',$endtime);

        $count = $this -> where($map) -> count();// 查询满足要求的总记录数
        $Page = new \Think\Page($count, 20);
        $show = $Page -> show();
        $result = $this ->where($map) ->order('part_id desc') ->limit($Page->firstRow.','.$Page->listRows) -> select();
        return array($result, $show);
    }

    /**
     * 删除作品
     */
    public function deleteProduct($p_id){
        return $this -> where("part_id = $p_id") -> delete();
    }

    /**
     *删除选中
     * @param $idArr
     * @return bool
     * @Date 201703
     * @Author Linsenquan
     */
    public function deleteAllPartUser($idArr)
    {
        foreach($idArr['id'] as $vo)
        {
            $this->where(array('part_id'=>$vo))->delete();
        }
        return true;
    }

}